import Mock from 'mockjs2'
import { builder } from '../util'

const totalCount = 5701

const wxList = () => {
  const result = []
  const pageNo = 0
  const pageSize = 30
  const totalPage = Math.ceil(totalCount / pageSize)
  const next = (pageNo >= totalPage ? (totalCount % pageSize) : pageSize) + 1

  for (let i = 1; i < next; i++) {
    result.push({
      id: Mock.mock('@id'),
      add_time: Mock.mock('@datetime'),
      wx_id: Mock.mock('@String(11)'),
      image: 'http://upload.chtmxp.cn/20191202/1575270054938.jpg'
    })
  }

  return builder({
    pageSize: pageSize,
    pageNo: pageNo,
    totalCount: totalCount,
    totalPage: totalPage,
    data: result
  })
}

Mock.mock(/\/weixin/, 'get', wxList)
